package com.yuanfeng.payment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuanfeng.commoms.config.YFConfig;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.RedisUtil;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.payment.dto.CheckRechargeCardDTO;
import com.yuanfeng.payment.entity.PayCardEntity;
import com.yuanfeng.payment.mapper.PayCardMapper;
import com.yuanfeng.payment.service.PayCardService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class PayCardServiceImpl extends ServiceImpl<PayCardMapper, PayCardEntity>
    implements PayCardService{

    @Override
    public ResponseResult query(CheckRechargeCardDTO param) {
        List<PayCardEntity> res = null;
        Map<Object, Object> map=new HashMap<>();
        if (RedisUtil.exists(YFConfig.YF_PLATFORM_TOKEN_USER + param.getToken())) {
            res = this.baseMapper.query(param);
            map.put("result",res);
            map.put("count",res.size());
        } else {
            return ResponseResult.fail(BizCodeEnume.INSUFFICIENT_PERMISSIONS);
        }
        return ResponseResult.success(BizCodeEnume.OPERATION_SUCCESSFUL.getMsg(),map);
    }
}




